import {
  ModalForm,
  ProFormText,
} from '@ant-design/pro-components';
import { useModel } from '@umijs/max';
import React, { PropsWithChildren } from 'react';

interface UpdateFormProps {
  children: any;
}
const CreateForm: React.FC<PropsWithChildren<UpdateFormProps>> = ({
  children,
}) => {
  const { addHandler } = useModel('Classroom.model', (model) => ({
    addHandler: model.addHandler,
  }));

  return (
    <ModalForm<API.Clr_Add_Body>
      trigger={children}
      title="教室新增"
      autoFocusFirstInput
      submitTimeout={2000}
      modalProps={{ destroyOnClose: true }}
      onFinish={addHandler}
    >
      <ProFormText
        name="clsr_name"
        label="教室名称"
        placeholder="请输入教室名称"
        rules={[
          { required: true, message: '教室名称为必填项!' },
          { min: 2, max: 20, message: '教室名称字数在2-20之间!' },
        ]}
      />
    </ModalForm>
  );
};

export default CreateForm;
